from flask import Flask, abort, jsonify, make_response, request
from send import qqbot


qq = qqbot(qq=2968652489, authKey="zl159753123", host="http://120.77.171.19:8080/")
app = Flask(__name__)


@app.route('/send_message', methods=['POST'])
def main():
    data = request.values
    if data.get('password') is None:
        return jsonify({'code': 401, 'reason': 'password defect'})
    elif data.get('password') != 'zl159753123':
        return jsonify({'code': 400, 'reason': 'password error'})
    else:
        qq.sendFriendMessage(data.get('number'), data.get('message'))
        return jsonify({'code': 200, 'reason': 'success'})


@app.route('/')
def hello_world():
    data = request.values
    print(data)
    return 'Hello World!'


if __name__ == '__main__':
    app.run(host="0.0.0.0", port=7900)
